import Vue from 'vue'
import Vuex from 'vuex'
import base from './modules/base'
import * as server from './service/base'
import { getLocalData } from '../utils/tools'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: {
      avatar: '',
    }
  },
  mutations: {
    setUser (state, { user }) {
      if (user) {
        state.user = user;
      } else {
        state.user = {};
      }
    },
  },
  actions: {
    async logins ({ commit }, data) {
      const {data: res} = await server.login(data)
      console.log(res)
    //  commit.setToken(res.token)
   }
  },
  getters: {
    token: state => state.base.token,
    user: state => state.user,
    layoutData: state => state.base.layoutData
  },
  modules: {
    base: base
  }
})
